/* eslint-disable @typescript-eslint/no-unused-vars */
import { request } from '@umijs/max';

/**
 * 分页形式获取医院列表数据，主要是给 ProTable 用
 * @param params 高级表格搜索传来的参数
 * @param sort
 * @param filter
 * @returns
 */
export const loadPermissionsInfoAPI = async (
  params: any & {
    pageSize: number;
    current: number;
  },
  sort: any,
  filter: any,
) => {
  // console.log(params);
  const { current, pageSize, ...other } = params;
  const msg = await request('/admin/permissions', {
    params: {
      ...other,
      page: current,
      per: pageSize,
    },
  });
  // console.log(msg);

  return {
    data: msg.data.list,
    success: true,
    total: msg.data.total,
  };
};

/**
 * 获取所有数据
 * @returns
 */
export const loadPermissionsAPI = () =>
  request('/admin/permissions', {
    params: {
      per: 1000,
    },
  });

/**
 * 获取对应 id 的医生数据
 * @param id
 * @returns
 */
export const loadPermissionsByIdAPI = (id: string) => request(`/admin/permissions/${id}`);

/**
 * 新增一条数据
 * @param data
 * @returns
 */
export const addPermissionsAPI = (data: any) =>
  request('/admin/permissions', { method: 'POST', data });

/**
 * 根据 id 修改医院信息
 * @param id
 * @returns
 */
export const modifyPermissionsInfoByIdAPI = (id: string, data: any) =>
  request(`/admin/permissions/${id}`, {
    method: 'PATCH',
    data,
  });

/**
 * 删除对应 id 的医生数据
 * @param id
 * @returns
 */
export const delPermissionsByIdAPI = (id: string) =>
  request(`/admin/permissions/${id}`, {
    method: 'DELETE',
  });

/**
 * 批量删除
 * @param ids 以逗号连接的字符串
 * @returns
 */
export const delManyPermissionsByIdsAPI = (ids: string) =>
  request('/admin/permissions/remove_many', {
    method: 'DELETE',
    params: {
      ids,
    },
  });
